#ifndef LOGOUTPUT_H
#define LOGOUTPUT_H

#include <iostream>
#include <queue>

#include "../concurrent/Mutex.h"
#include "../concurrent/Thread.h"
#include "../concurrent/ReaderWriter.h"

#include "Types.h"
#include "Entry.h"
#include "Appender.h"
#include "AppenderFactory.h"

namespace logging {

typedef std::map<std::string, Appender*, ltstr> AppenderMap;
typedef std::queue<Entry*> EntryQueue;

class LogOutput : public concurrent::Thread
{
public:
	LogOutput();
	~LogOutput();
	
	void log(Entry *entry);

protected:
	virtual void run();
	virtual void teardown();
	
private:
	inline void write();

	concurrent::Mutex _mutex;
	EntryQueue _queue;

	concurrent::ReaderWriter _lock;
	AppenderMap _appenders;
};


}

#endif /* LOGOUTPUT_H */
